LWG issue 2341; Make the two variants of basic_ostream::seekp and basic_istream::seekg behave consistently; update tests to make sure git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@193814 91177308-0d34-0410-b5e6-96231b3b80d8 
diff --git a/include/istream b/include/istream index 7284fc1..14fa466 100644 --- a/include/istream +++ b/include/istream 
@@ -1369,8 +1369,10 @@  this->clear(this->rdstate() & ~ios_base::eofbit);  sentry __sen(*this, true);  if (__sen) + {  if (this->rdbuf()->pubseekpos(__pos, ios_base::in) == pos_type(-1))  this->setstate(ios_base::failbit); + }  #ifndef _LIBCPP_NO_EXCEPTIONS  }  catch (...) @@ -1391,7 +1393,10 @@  #endif // _LIBCPP_NO_EXCEPTIONS  sentry __sen(*this, true);  if (__sen) - this->rdbuf()->pubseekoff(__off, __dir, ios_base::in); + { + if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::in) == pos_type(-1)) + this->setstate(ios_base::failbit); + }  #ifndef _LIBCPP_NO_EXCEPTIONS  }  catch (...) 
diff --git a/include/ostream b/include/ostream index 2c618d4..041314a 100644 --- a/include/ostream +++ b/include/ostream 
@@ -1159,7 +1159,8 @@  basic_ostream<_CharT, _Traits>&  basic_ostream<_CharT, _Traits>::seekp(pos_type __pos)  { - if (!this->fail()) + sentry __s(*this); + if (__s)  {  if (this->rdbuf()->pubseekpos(__pos, ios_base::out) == pos_type(-1))  this->setstate(ios_base::failbit); @@ -1172,8 +1173,12 @@  basic_ostream<_CharT, _Traits>&  basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir)  { - if (!this->fail()) - this->rdbuf()->pubseekoff(__off, __dir, ios_base::out); + sentry __s(*this); + if (__s) + { + if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::out) == pos_type(-1)) + this->setstate(ios_base::failbit); + }  return *this;  }